using System;
using PPIDesktopClient.Logic;
using System.Collections.Generic;
using PPIDesktopClient.General;
using System.Text;

namespace PPIDesktopClient.Entities
{
    [Serializable]
    public class EUtility_Asset_XMissionStructures_Pole : EBasePole
    {
        private List<EUtility_Asset_XMissionStructures_Image> m_Images;
        public List<EUtility_Asset_XMissionStructures_Image> Images
        {
            get
            {
                return m_Images;
            }
            set
            {
                m_Images = value;
            }
        }

        private EUtility_Asset_XMissionStructure m_Asset;
        public EUtility_Asset_XMissionStructure Asset
        {
            get
            {
                return m_Asset;
            }
            set
            {
                m_Asset = value;
            }
        }

        #region Constructores
        #region summary
        /// <summary>
        /// Date: 04/28/2008
        /// Time: 13:09:22
        /// Generated by: VMCoder
        /// Generated using VirtualGenerator
        /// </summary>
        #endregion summary
        public EUtility_Asset_XMissionStructures_Pole()
            : base()
        {
            m_Images = new List<EUtility_Asset_XMissionStructures_Image>();
        }

        #region summary
        /// <summary>
        /// Date: 04/28/2008
        /// Time: 13:09:22
        /// Generated by: VMCoder
        /// Generated using VirtualGenerator
        /// </summary>
        #endregion summary
        public EUtility_Asset_XMissionStructures_Pole(Int32 poleID)
            : this()
        {
            Id = poleID;

        }

        #region summary
        /// <summary>
        /// Date: 04/28/2008
        /// Time: 13:13:16
        /// Generated by: VMCoder
        /// Generated using VirtualGenerator
        /// </summary>
        #endregion summary
        public EUtility_Asset_XMissionStructures_Pole(Int32 poleId, EUtility_Asset_XMissionStructure asset, EXMissionStructures_PoleTopType xMissionStructures_PoleTopType, EXMissionStructures_PoleSpecies xMissionStructures_PoleSpecies, EXMissionStructures_PoleTreatment xMissionStructures_PoleTreatment, Int32 year, EXMissionStructures_PoleClass xMissionStructures_PoleClass, double latitude, double longitude, double altitude, Int32 satelliteCount, DateTime satelliteTime, bool solutionAvailable, string aID, Int32 lVisit, string number, double length, string lVisitor)
            : this(poleId)
        {
            Asset = asset;
            TopType = xMissionStructures_PoleTopType;
            Species = xMissionStructures_PoleSpecies;
            Treatment = xMissionStructures_PoleTreatment;
            Year = year;
            Class = xMissionStructures_PoleClass;
            Latitude = latitude;
            Longitude = longitude;
            Altitude = altitude;
            SatelliteCount = satelliteCount;
            SatelliteTime = satelliteTime;
            SolutionAvailable = solutionAvailable;
            AID = aID;
            LVisit = lVisit;
            Number = number;
            Length = length;
            LVisitor = lVisitor;

        }

        #endregion Constructores

        #region Override
        public override int Save()
        {
            if (Id == Int32.MinValue)
            {
                Id = Insert();
            }
            else
            {
                Update();
            }

            foreach (Int32 item in DeletedImages)
            {
                LUtility_Asset_XMissionStructure_Image.Disassociate(item);
            }
            foreach (EBaseImage i in m_Images)
            {
                i.Associate(Id);
            }
            return Id;
        }
        protected override int Insert()
        {
            int id = LUtility_Asset_XMissionStructure_Pole.Insert(this);

            return id;
        }
        protected override void Update()
        {
            LUtility_Asset_XMissionStructure_Pole.Update(this);
        }
        public override void Delete()
        {
            foreach (EBaseImage i in m_Images)
            {
                i.Disassociate();
            }
            LUtility_Asset_XMissionStructure_Pole.Delete(Id);
        }

        public override string GetHtmlDescription()
        {
            StringBuilder _Shtml = new StringBuilder();
            _Shtml.AppendLine("<table style='backgroundcolor:#ffffff' border='0'>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td><b>Pole " + Id + "</b></td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Top Type: " + TopType.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Species: " + Species.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Year: " + Year + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Treatment: " + Treatment.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Length: " + Length + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Class: " + Class.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Lat: " + Latitude.ToString("F6") + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Long: " + Longitude.ToString("F6") + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Alt: " + Altitude.ToString() + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Last Visitor: " + LVisitor + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Last Visit: " + LVisit + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Number: " + Number + "</td>");
            _Shtml.AppendLine(" </tr>");


            foreach (EBaseImage i in Images)
            {
                _Shtml.AppendLine(" <tr>");
                _Shtml.AppendLine(i.GetHtml());
                _Shtml.AppendLine(" </tr>");
            }
            _Shtml.AppendLine("</table>");
            return _Shtml.ToString();
        }

        protected override string GetPlacemarkId()
        {
            return "UtilityPole_" + Id.ToString();
        }

       #endregion

        #region Public Methods
        public void Desasocciate(Int32 imageID)
        {

        }


        #endregion

    }
}

